import { fetchCount } from "../features/counter/counterAPI";
import { SendState } from "../pages/disease/write";
import { getHttp, postHttpForm, postHttpJSON } from "../service/request";

// 获取科室列表
export function getDiseaseTitle() {
  return getHttp({ url: "/health/share/knowledgeBase/v1/findDepartment" });
}

interface ParamsState {
  departmentId: number;
  count: number;
  page: number;
}
// 获取病友圈 详情
export function getDiseaseListById(params: ParamsState) {
  return getHttp({
    url: "/health/user/sickCircle/v1/findSickCircleList",
    params,
  });
}

// 获取科室 对应的疾病列表
export function getDiseaseLis(departmentId: number) {
  return getHttp({
    url: "/health/share/knowledgeBase/v1/findDiseaseCategory",
    params: {
      departmentId,
    },
  });
}

// 发布
export function publishDisease(data: SendState) {
  return postHttpJSON({
    url: "/health/user/sickCircle/verify/v1/publishSickCircle",
    data: data,
  });
}

// 发布 图片
export function uploadImageDisease(sickCircleId: string, picture: File) {
  const form = new FormData();
  form.append("sickCircleId", sickCircleId);
  form.append("picture", picture);

  return postHttpJSON({
    url: "/health/user/sickCircle/verify/v1/uploadSickCirclePicture",
    data: form,
  });
}
